package com.taiyuan.tongcheng.view.multichecklistview;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.Checkable;
import android.widget.ImageView;
/**
 * 
* @Description 选中效果的
* @author wzq
* @date 2015-8-6 下午4:39:04
* @update (date)
* @version V1.0
 */
public class CheckableImageView  extends ImageView implements Checkable {

	private boolean isChecked = false;
	private int checkImgID;
	private int dafaultImgID;
	
	public CheckableImageView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	public CheckableImageView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public CheckableImageView(Context context) {
		super(context);
	}
	
	public void setCheckImgID(int checkImgID) {
		this.checkImgID = checkImgID;
	}
	
	public void setDafaultImgID(int dafaultImgID) {
		this.dafaultImgID = dafaultImgID;
	}
	
	@Override
	public void setChecked(boolean checked) {
		setBackgroundResource(checked?checkImgID:dafaultImgID);
	}

	@Override
	public boolean isChecked() {
		return isChecked;
	}

	@Override
	public void toggle() {
		isChecked=!isChecked;
	}  

	
}
